<template>
    <div>
        <div style="margin-top: 1%">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item >首页</el-breadcrumb-item>
                <el-breadcrumb-item>采购申请单</el-breadcrumb-item>
                <el-breadcrumb-item>新增</el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <el-form :model="form" :rules="rules" ref="ruleform" label-width="140px">
            <el-row>
                <el-col :span="12">
                    <el-form-item label="日期"  prop="addtime">
                        <el-input v-model="form.addtime" autocomplete="off"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="单据编号"  prop="djbh" >
                        <el-input v-model="form.djbh" autocomplete="off"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="12">
                    <el-form-item label="审核标志"  prop="shbz">
                        <el-input v-model="form.shbz" autocomplete="off"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="关闭标志"  prop="gbbz" >
                        <el-input v-model="form.gbbz" autocomplete="off"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="12">
                    <el-form-item label="使用部门"  prop="sybm">
                        <el-input  v-model="form.sybm" autocomplete="off"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="计划订单号"  prop="jhddh">
                        <el-input  v-model="form.jhddh" autocomplete="off"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="12">
                    <el-form-item label="物料长代码"  prop="wlzdm">
                        <el-input  v-model="form.wlzdm" autocomplete="off"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="物料名称"  prop="wlmc">
                        <el-input  v-model="form.wlmc" autocomplete="off"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="12">
                    <el-form-item label="数量"  prop="suliang">
                        <el-input v-model="form.suliang" autocomplete="off"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="到货日期"  prop="dhrq">
                        <el-input  v-model="form.dhrq" autocomplete="off"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="12">
                    <el-form-item label="供应商名称"  prop="gysmc">
                        <el-input v-model="form.gysmc" autocomplete="off"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="建议采购日期"  prop="jycgrq">
                        <el-input type="number" v-model="form.jycgrq" autocomplete="off"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="12">
                    <el-form-item label="换算率"  prop="hsl">
                        <el-input  v-model="form.hsl" autocomplete="off"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
        </el-form>
        <div slot="footer" class="dialog-footer">
            <el-button @click="resetForm">重 置</el-button>
            <el-button type="primary" @click="handleConfine">确 定</el-button>
        </div>
    </div>
</template>

<script>
  export default {
    name: 'index',
    data(){
      return{
        form: {
          id:1,
          addtime: '',
          djbh: '',
          shbz: '',
          gbbz: '1',
          sybm: '',
          jhddh: '',
          wlzdm: '',
          wlmc: '',
          suliang: '',
          dhrq: '',
          gysmc: '',
          jycgrq: '',
          hsl: '',
        },
        labelWidth:'100px',
        rules: {
          addtime: [
            { required: true, message: '日期', trigger: 'blur' },
          ],
          djbh: [
            { required: true, message: '单据编号', trigger: 'blur' },
          ],
          shbz: [
            { required: true, message: '审核标志', trigger: 'blur' },
          ],
          gbbz: [
            { required: true, message: '关闭标志', trigger: 'blur' },
          ],
          sybm: [
            { required: true, message: '使用部门', trigger: 'blur' },
          ],jhddh: [
            { required: true, message: '计划订单号', trigger: 'blur' },
          ],wlzdm: [
            { required: true, message: '物料长代码', trigger: 'blur' },
          ],wlmc: [
            { required: true, message: '物料名称', trigger: 'blur' },
          ],suliang: [
            { required: true, message: '数量', trigger: 'blur' },
          ],dhrq: [
            { required: true, message: '到货日期', trigger: 'blur' },
          ],hsl: [
            { required: true, message: '换算率', trigger: 'blur' },
          ],zje: [
            { required: true, message: '总金额', trigger: 'blur' },
          ],shr: [
            { required: true, message: '审核人', trigger: 'blur' },
          ],yfrq: [
            { required: true, message: '应付日期', trigger: 'blur' },
          ],yfje: [
            { required: true, message: '应付金额', trigger: 'blur' },
          ],
        }
      }
    },
    methods:{
      //确认添加
      handleConfine() {
        var validate = false;
        this.$refs['ruleform'].validate((valid) => {
          if (valid) {
            validate = true;
          } else {
            console.log('error submit!!');
            validate = false;
            return false;
          }
        });
        if (validate === false) {
          return;
        }
        setTimeout(()=>{
          this.form.id = Math.ceil(Math.random()*100);
          // this.tableData.push(this.form);
          // this.$store.commit('addSkuDatas',this.form)
          this.addcangkuDatas(this.form)
        },2000)
        this.showAddDialog = false;
        this.$message.success("添加成功!");

      },
      resetForm() {
        this.$refs['ruleform'].resetFields();
      },
    }
  };
</script>

<style scoped>

</style>
